﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuantitativeInvestment.Bean;
namespace QuantitativeInvestment.Factor
{
    class ReturnFactor:Factor
    {
        public ReturnFactor()
        {
            this.name = "收益率";
            Parameter p = new Parameter("天数", 30);
            this.paraList.Add(p.name, p);
        }

        public override void addFactorValue(Stock stock)
        {
            int num=Int32.Parse(this.paraList["天数"].value.ToString());
            if (!stock.factors.ContainsKey(this.name))
            {
                if (stock.factors.ContainsKey("价格"))
                {
                    double[] closePrices = stock.factors["价格"];
                    double[] returns = new double[closePrices.Length];
                    for (int i = num; i < closePrices.Length; i++)
                    {
                        returns[i] = (closePrices[i] - closePrices[i - num]) / closePrices[i - num];
                    }
                }
                stock.factors.Add(this.name+this.paraList["天数"].value.ToString(),null );
             
            }
        }

    }
}
